package com.kangyi.admin.mapper;

import com.github.pagehelper.Page;
import com.kangyi.admin.annotation.AutoFill;
import com.kangyi.dto.PublicActivityPageDTO;
import com.kangyi.entity.PublicActivity;
import com.kangyi.enumeration.OperationType;
import com.kangyi.vo.PublicActivityDetailVO;
import com.kangyi.vo.PublicActivityPageVO;
import io.swagger.annotations.ApiModelProperty;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author Blank
 * @version 1.0
 */
@Mapper
public interface PublicActivityMapper {

    @Select("SELECT COUNT(*) FROM activity_signup WHERE activity_id = #{activityId}")
    Long countActivityId(Integer activityId);

    Page<PublicActivityPageVO> pageQuery(PublicActivityPageDTO publicActivityPageDTO);

    @AutoFill(value = OperationType.INSERT)
    void addPublicActivity(PublicActivity publicActivity);

    PublicActivityDetailVO detailPublicActivity(Integer id);

    @AutoFill(value = OperationType.UPDATE)
    void editPublicActivity(PublicActivity publicActivity);


    @Select("select * from public_activity where id = #{id};")
    PublicActivity getById(Integer id);

    @Delete("delete from public_activity where id = #{id};")
    void deleteById(Integer id);

    @Update("update public_activity set admin_user_id = 1 where admin_user_id = #{id};")
    @AutoFill(value = OperationType.UPDATE)
    void updateByUserId(Integer id);

    @Select("select count(*) from public_activity where inviter_id = #{inviterId};")
    int countByInviterId(Integer inviterId);
}
